  /*package org.kukker.upcoming;

import java.io.IOException;
import java.util.List;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;

import android.content.Context;
import android.util.Log;
  
      public class UpcomingHandler extends DefaultHandler {
  
    
            // Used to define what elements we are currently in
           private boolean inItem = false;
  
           private boolean inTitle = false;
          private boolean inLink = false;
         
         // Feed and Article objects to use for temporary storage
          private org.kukker.upcoming.Event event;
          private List<org.kukker.upcoming.Event> events;
            
      
          private int targetFlag;
         
  
       
  
          public void startElement(String uri, String name, String qName, Attributes atts) {  
              if (name.trim().equals("rsp"))  
                  inTitle = true;
              else if (name.trim().equals("item"))  
                  inItem = true;  
              else if (name.trim().equals("link"))  
                  inLink = true;  
          }
  
       
  
          public void endElement(String uri, String name, String qName) throws SAXException {  
              if (name.trim().equals("title"))  
                  inTitle = false;  
            else if (name.trim().equals("item"))  
                  inItem = false;  
              else if (name.trim().equals("link"))  
                  inLink = false;   
  
              // Check if looking for feed, and if feed is complete
  
              if (targetFlag == TARGET_FEED && currentFeed.url != null 
                      && currentFeed.title != null) {
         
                  // We know everything we need to know, so insert feed and exit  
                  droidDB.insertFeed(currentFeed.title, currentFeed.url);  
                  throw new SAXException();  
              }
  
              // Check if looking for article, and if article is complete
  
              if (targetFlag == TARGET_ARTICLES && currentArticle.url != null
  
                      && currentArticle.title != null) {
  
                  droidDB.insertArticle(currentFeed.feedId, currentArticle.title,
  
                          currentArticle.url);
  
                  currentArticle.title = null;
  
                currentArticle.url = null;
  
       
  
                  // Lets check if we've hit our limit on number of articles
  
                  articlesAdded++;
  
                  if (articlesAdded >= ARTICLES_LIMIT)
  
                      throw new SAXException();
  
              }
  
       
  
          }
  
       
  
          public void characters(char ch[], int start, int length) {
  
       
  
              String chars = (new String(ch).substring(start, start + length));
  
       
  
              try {
  
                  // If not in item, then title/link refers to feed
  
                  if (!inItem) {
  
                      if (inTitle)
  
                          currentFeed.title = chars;
  
                  } else {
 
                      if (inLink)
 
                          currentArticle.url = new URL(chars);
 
                      if (inTitle)
 
                          currentArticle.title = chars;
 
                  }
 
              } catch (MalformedURLException e) {
 
                  Log.e("NewsDroid", e.toString());
 
              }
 
       
 
          }
 
       
 
          public void createFeed(Context ctx, URL url) {
 
             try {
 
                  targetFlag = TARGET_FEED;
 
                  droidDB = new NewsDroidDB(ctx);
 
                  currentFeed.url = url;
 
      
 
                  SAXParserFactory spf = SAXParserFactory.newInstance();
 
                  SAXParser sp = spf.newSAXParser();
 
                  XMLReader xr = sp.getXMLReader();
 
                 xr.setContentHandler(this);
 
                  xr.parse(new InputSource(url.openStream()));
 
                 
 
              } catch (IOException e) {
 
                Log.e("NewsDroid", e.toString());
 
              } catch (SAXException e) {
 
                  Log.e("NewsDroid", e.toString());
 
              } catch (ParserConfigurationException e) {
 
                  Log.e("NewsDroid", e.toString());
 
              }
 
          }
 
       
 
          public void updateArticles(Context ctx, Feed feed) {
 
             try {
 
                  targetFlag = TARGET_ARTICLES;
 
                  droidDB = new NewsDroidDB(ctx);
 
                  currentFeed = feed;
 
      
 
                  SAXParserFactory spf = SAXParserFactory.newInstance();
 
                  SAXParser sp = spf.newSAXParser();
 
                  XMLReader xr = sp.getXMLReader();
 
                  xr.setContentHandler(this);
 
                xr.parse(new InputSource(currentFeed.url.openStream()));
 
              
 
              } catch (IOException e) {
 
                  Log.e("NewsDroid", e.toString());
 
              } catch (SAXException e) {
 
                  Log.e("NewsDroid", e.toString());
 
              } catch (ParserConfigurationException e) {
 
                  Log.e("NewsDroid", e.toString());
 
             }
 
          }
 
       
 
      }

*/